package com.dingwen.stusprboomon.constant.eum;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
 * 方法入参类型
 *
 * @author dingwen
 * 2021.06.24 09:21
 */
@Getter
@AllArgsConstructor
public enum ParamEnum {

    /**
     * 参数类型
     */
    PAGE_SIZE("pageSize", "页面大小"),
    PAGE_NUM("pageNum", "页数"),
    SORT("sort", "mongo 查询，排序规则");

    /**
     * 参数名称
     */
    private final String name;


    /**
     * 描述
     */
    private final String description;


    /**
     * 得到参数枚举
     *
     * @param name 的名字
     * @return {@link ParamEnum}
     */
    public static ParamEnum getParamEnum(String name) {
        Predicate<ParamEnum> paramConstantPredicate = paramEnum -> paramEnum.name.equalsIgnoreCase(name);
        List<ParamEnum> paramEnumList = Arrays.stream(ParamEnum.values()).filter(paramConstantPredicate).collect(Collectors.toList());
        return paramEnumList.get(0);
    }


}
